package com.yunc.user.mq.rocketmq;

import com.yunc.common.disruptor.DisruptorService;
import com.yunc.user.mq.disruptor.SysUserUpdateEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Service;

/**
 * @author taocongcong
 * @create 2021-05-21 14:21
 */
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @_(@Autowired))
public class ShopOrderListener {

    private final DisruptorService disruptorService;

    @StreamListener(CustomChannel.INPUT_ORDER_TOPIC)
    public void receive(String message) {
        disruptorService.publishEvent(
                SysUserUpdateEvent.builder()
                .userId("2")
                .extendId("3")
                .build()
        );
        log.info("接收stream到订单更新新消息：" + message);
    }
}
